#pragma once
#include <algorithm>
#include <cstdlib>
#include <deque>
#include <functional>
#include <vector>

namespace BTLU {

// 参数：节点距离根节点的距离，以及节点编号
typedef std::function<void(int, int)> Visitor;
typedef std::function<void(int node, std::deque<int> &q)> ExamineNode;
typedef std::function<void(int node, int level, std::deque<int> &q)> FinishNode;
// 有向不带权图
class Graph {
  private:
    int _n;
    std::vector<std::pair<int, int>> _key_nodes;
    std::vector<int> _l2g, _g2l;
    std::vector<std::vector<int>> _edges;
    void BFS(int start, int *color_map, ExamineNode examine, FinishNode finish, int color);
  public:
    Graph(int n, int *row, int *col, int *degrees, int threshold);
    void RcmWithDegree(int *perm);
};

}  // namespace BTLU
